package de.sp.games.snake12k.boxes;

import java.util.ArrayList;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public abstract class Box {
	
	protected int x;
	protected int y;
	protected int indexX;
	protected int indexY;
	
	protected Image boxImage;
	protected boolean isCollision = false;
	protected boolean isChangeable = false;
	
	//TODO: x, y loeschen -> x = indexX * 16 | y = indexY * 16
	public Box(final int x, final int y, final Image boxImage,
					final int indexX, final int indexY) throws SlickException {
		
		if(x >= 0 && y >= 0) {
			this.x = x;
			this.y = y;
		} else {
			System.out.println("Unexcepted Box Value: Under Zero!");
			throw new IllegalArgumentException();
		}
		
		this.boxImage = boxImage;  
		boxImage.setFilter(Image.FILTER_NEAREST);
		this.indexX = indexX;
		this.indexY = indexY;
	}
	
	/* Hollow box, not rly save... */
	public Box() {
		
	}
	
	public void draw(Graphics g) {
		boxImage.draw(x, y);
		//g.setColor(Color.black);
		//g.drawString(String.valueOf(indexX), x, y);
	}
	
	public void update(GameContainer gc, ArrayList<Box> boxList) throws SlickException {
		//TODO: In der For-Schleife nach Instanz fragen
		// ->  die Methode hier loeschen
	}
	
	public boolean isChangeable() {
		return this.isChangeable;
	}
	
	public boolean isCollision() {
		return this.isCollision;
	}
	
	public int getIndexX() {
		return this.indexX;
	}
	
	public int getIndexY() {
		return this.indexY;
	}
}
